package it.yuzuojian.com.service.impl;

import it.yuzuojian.com.dao.SongAndSongListMapper;
import it.yuzuojian.com.domain.SongAndSongList;
import it.yuzuojian.com.service.SongAndSongListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SongAndSongListServiceImpl implements SongAndSongListService {
    @Autowired
    private SongAndSongListMapper songAndSongListMapper;
    @Override
    public Boolean insert(SongAndSongList songAndSongList) {
        return songAndSongListMapper.insert(songAndSongList)>0;
    }

    @Override
    public Boolean delete(Integer[] songId, Integer songListId[]) {
        Boolean flag=true;
        for (int i = 0; i < songId.length; i++) {
            if(songAndSongListMapper.delete(songId[i],songListId[i])==0){
                flag=false;
            }
        }
        return flag;
    }

    @Override
    public List<SongAndSongList> selectBySongListId(Integer songListId) {
        return songAndSongListMapper.selectBySongListId(songListId);
    }
}
